package com.speedata

import android.annotation.SuppressLint
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import com.android.internal.widget.RecyclerView
import com.speedata.uhftest.R

class MainActivity2 : AppCompatActivity(), View.OnClickListener {

    var bt1: Button? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main2)
        initView()

    }

    private fun initView() {
        bt1 = findViewById(R.id.tv_one)
        bt1!!.setOnClickListener(this)

        var recyclerView : RecyclerView ? = null

    }

    @SuppressLint("SetTextI18n")
    override fun onClick(v: View) {
        when (v.id) {
            R.id.tv_one -> {
                bt1?.text = "ok"
                open()
            }
        }
    }

    private fun open() {

        try {

            for (i in 1..10) {
                for (j in 10 downTo 1) {
                    foo(1)
                }
            }

        } catch (e: Exception) {

            e.printStackTrace()

            Log.d("test", e.message)

        }

    }

    fun foo(j: Int) {
        val a = arrayOf(1, 2, 3, 4, 5)
        Log.d("test", j.toString())
        getResult()
    }

    fun getResult() {
        val a = 1
        var b = ""
        Log.d("test", a.toString())

        when (a) {
            1 -> {

                b = "def"

                Log.d("test", b)
            }
            else -> {

            }

        }
    }


}